package sctu.edu.java.year2016.team01.xuhanmei.day20160619;

import java.io.*;

/**
 * Created by Administrator on 2016/6/19.
 */
public class LearnReader {
    public static void main(String[] args) {
        File src=new File("d:/java小程序/LearnReader.txt");

        Reader r=null;
        try {
            r=new FileReader(src);
            char[] c=new char[10];
            int len=0;
            while (-1!=(len=r.read(c))){

                String s=new String(c,0,len);
                System.out.println(s);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
            System.out.println("文件不存在！");
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("文件读取失败！");
        }
        finally {
            if(null!=r){
                try {
                    r.close();
                } catch (IOException e) {
                    e.printStackTrace();
                    System.out.println("filereader关闭失败！");
                }
            }
        }
    }
}
